package com.itheima.a02jdk8datedemo;

import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

public class DateTimeFormatterDemo1 {
    public static void main(String[] args) {
        //获取格式对象
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        //获取时间对象
        ZonedDateTime now = ZonedDateTime.now();
        //按照指定方式格式化
        String format = dateTimeFormatter.format(now);
        System.out.println(format);
    }
}
